home *** CD-ROM | disk | FTP | other *** search
/ Total Animated Gifs / Total Animated Gifs.iso / Utilities / text / jseditor / jseditor.exe / fade.js next >
Text File  |  1998-06-30  |  1KB  |  53 lines

  1. /*************************************************************
  2.  * fade script ver0.1 by Kouichirou@Eto.com 1996/02/20
  3.  * Copyright (c) 1996 Kouichirou Eto. All Rights Reserved.
  4.  * You can freely copy, use, modify this script,
  5.  * if the credit is given in the source.
  6.  */
  7.  
  8. function makearray(n) {
  9.     this.length = n;
  10.     for(var i = 1; i <= n; i++)
  11.         this[i] = 0;
  12.     return this;
  13. }
  14.  
  15. hexa = new makearray(16);
  16. for(var i = 0; i < 10; i++)
  17.     hexa[i] = i;
  18. hexa[10]="a"; hexa[11]="b"; hexa[12]="c";
  19. hexa[13]="d"; hexa[14]="e"; hexa[15]="f";
  20.  
  21. function hex(i) {
  22.     if (i < 0)
  23.         return "00";
  24.     else if (i > 255)
  25.         return "ff";
  26.     else
  27.         return "" + hexa[Math.floor(i/16)] + hexa[i%16];
  28. }
  29.  
  30. function setbgColor(r, g, b) {
  31.     var hr = hex(r); var hg = hex(g); var hb = hex(b);
  32.     document.bgColor = "#"+hr+hg+hb;
  33. }
  34.  
  35. function fade(sr, sg, sb, er, eg, eb, step) {
  36.     for(var i = 0; i <= step; i++) {
  37.         setbgColor(
  38.         Math.floor(sr * ((step-i)/step) + er * (i/step)),
  39.         Math.floor(sg * ((step-i)/step) + eg * (i/step)),
  40.         Math.floor(sb * ((step-i)/step) + eb * (i/step)));
  41.     }
  42. }
  43.  
  44. function fadein() {
  45.     /* HOMESITE */
  46. }
  47.  
  48. /* do fadein */
  49. fadein();
  50.  
  51. /***** end fade script *****/
  52. /************************************************************/
  53.